# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        黄周云  
# Name:         test14_1
# Description:  例14.1
# Author:       ASUS
# Date:         2019/4/17
#-------------------------------------------------------------------------------


from xml.etree.ElementTree import parse
# 读取文件
doc = parse('files/products.xml')
print(type(doc))
#对子节点集合进行迭代
for item in doc.iterfind('products/product'):
    #读取product节点的id子节点的值
    id = item.findtext('id')
    name = item.findtext('name')
    price = item.findtext('price')
    #读取product节点的uuid属性
    print('uuid','=',item.get('uuid'))
    print('id', '=', id)
    print('name', '=', name)
    print('price', '=', price)
    print("---------------------")



